import React, { Component } from 'react'
// 1.引入头部组件
import Header from '../../components/Header/Header'
import { Link } from "react-router-dom";

import { Form, Input, Button, Toast } from 'antd-mobile'
// import { reqlogin } from '../../http/api'
import { connect } from "react-redux";
import { actions, getUser } from "../../store/modules/login";
import { bindActionCreators } from "redux";

class Login extends Component {
 
  

  render() {
    let { user,l:{changeUser,doLogin},history:{push} } = this.props;
    return (
      <div>
        <Header back register title="登录"></Header>
        {/* <div>user:{JSON.stringify(user)}</div> */}
        <Form layout='horizontal'>
          <Form.Item label='手机号' name='phone'>
            <Input placeholder='请输入手机号'
              clearable
              onChange={(value) => {changeUser("phone",value) }}
            />
          </Form.Item>
          <Form.Item label='密码' name='password'>
            <Input placeholder='请输入密码' clearable
              type='password'
              onChange={(value) => {changeUser( "password",value) }}
            />
          </Form.Item>
          <Button block color='danger' size='large'
          onClick={()=>{doLogin(push)}}
          >登录</Button>
        </Form>

      </div>
    )
  }
}
const mapStateToProps = (state)=>{
  return {
    user:getUser(state)
  }
}
const mapDispatchToProps = (dispatch)=>{
  return {
    l: bindActionCreators(actions, dispatch),
  }
}



export default connect(mapStateToProps, mapDispatchToProps)(Login);
